﻿using System;
using System.Net;
using System.Collections.Generic;

using System.Runtime.Serialization;

namespace TicTacGadget.Web.Services
{
    public class Move 
    {
        public int X { get; set; }
        public int Y { get; set; }
        public int Sequence { get; set; }
        public string Player { get; set; }
        public Guid Host { get; set; }
    }

    /// <summary>
    /// Base message class. Please add [KnownType] attributes as necessary for every 
    /// derived message type.
    /// </summary>
    [KnownType(typeof(InquiryMessage))]
    [KnownType(typeof(GameMessage))]
    [KnownType(typeof(MoveMessage))]
    [KnownType(typeof(ConnectMessage))]
    [KnownType(typeof(DisconnectMessage))]
    [DataContract(Namespace = "http://samples.microsoft.com/silverlight2/duplex")]
    public class DuplexMessage
    {
    }

    public class InquiryMessage : DuplexMessage
    {
        public Guid RequestedBy { get; set; }
    }

    public class GameMessage : DuplexMessage
    {
        public Guid GameId { get; set; }
        public Guid HostedBy { get; set; }
        public Move[] Moves { get; set; }
    }

    public class MoveMessage : DuplexMessage
    {
        public Guid GameId { get; set; }
        public Move Move { get; set; }
    }

    /// <summary>
    /// Standard "Connect" message - clients may use this message to connect, when no other payload is required
    /// </summary>
    [DataContract(Namespace = "http://samples.microsoft.com/silverlight2/duplex")]
    public class ConnectMessage : DuplexMessage { }

    /// <summary>
    /// Standard "Disconnect" message - clients must use this message to disconnect
    /// </summary>
    [DataContract(Namespace = "http://samples.microsoft.com/silverlight2/duplex")]
    public class DisconnectMessage : DuplexMessage { }
}
